package com.chaoyong.higo.utils;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {
	private static final int VERSION = 1;
	private static final String DATABASES_NAME = "data.db";
	public static final String SHOP_INFO="shopinfo";
    public DatabaseHelper(Context context) {
		//必须通过super调用父类当中的构造函数
		super(context, DATABASES_NAME, null, VERSION);
	}
    //该函数是在第一次创建的时候执行，实际上是第一次得到SQLiteDatabase对象的时候才会调用这个方法
    @Override
    public void onCreate(SQLiteDatabase db) {
    	String record_one_SQL = "CREATE TABLE IF NOT EXISTS "+ SHOP_INFO+
    			"(id VARCHAR(30),"+
    			"name VARCHAR(30)," +
    			"price VARCHAR(30),"+
    			"count VARCHAR(30),"+
    			"left VARCHAR(30),"+
    			"image VARCHAR(30)";
    	
    	
    	try {
    		db.execSQL(record_one_SQL);
    		Mlog.d("创建表");
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		Mlog.d("old = " + oldVersion + " new =" + newVersion);
	}
	
	
	

}
